<!--#include file="../inc/vbfuns.asp"-->
<!--#include file="../inc/conn.inc.asp"-->
<!--#include file="../inc/chkexist.asp"-->
<%
	on error resume next
	session.timeout=120

	'==========================================================================	
	set oRs=conn.execute("select top 1 * from weixin")
	if not oRs.eof then
		appId=oRs("appId")
		appSecret=oRs("appSecret")
		access_token=oRs("access_token")
		Session("appid")=appId
	end if
	'==========================================================================
	if len(request("from"))>5 then Session("us_s")=SafeReq(request("us_s"))
	if (Request("code")="") and isWeixin then
		Response.Redirect "https://open.weixin.qq.com/connect/oauth2/authorize?appid="&appId&"&redirect_uri="&Server.URLEncode(appurl &"?us_id=" & us_id)&"&response_type=code&scope=snsapi_base&state=STATE&connect_redirect=1#wechat_redirect"
	end if
	wx=val(request("wx"))
	if wx then
		'Response.Redirect "https://open.weixin.qq.com/connect/oauth2/authorize?appid="&appId&"&redirect_uri="&Server.URLEncode(appurl &"?us_id=" & us_id)&"&response_type=code&scope=snsapi_base&state=STATE&connect_redirect=1#wechat_redirect"
	end if
	'==========================================================================
	'朋友圈   from=timeline'微信群   from=groupmessage'好友分享 from=singlemessage
	if len(request("from"))>5 then
		Response.Redirect "https://open.weixin.qq.com/connect/oauth2/authorize?appid="&appId&"&redirect_uri="&Server.URLEncode(appurl &"?us_id=" & us_id)&"&response_type=code&scope=snsapi_base&state=STATE&connect_redirect=1#wechat_redirect"
	end if
	'==========================================================================	
	if (Request("code")<>"") and isWeixin then
		'set oRs=conn.execute("select top 1 * from weixin where us_id="&us_id)
		if not oRs.eof then
			'appId=oRs("appId")
			'appSecret=oRs("appSecret")
			'access_token=oRs("access_token")
			xml_text=post("https://api.weixin.qq.com/sns/oauth2/access_token?appid="&appId&"&secret="&appSecret&"&code="&Request("code")&"&grant_type=authorization_code","")
			set java_obj=java_eval("(" &xml_text& ")")
			openid=java_obj.openid
			xml_text=post("https://api.weixin.qq.com/cgi-bin/user/info?access_token="&access_token&"&openid="&openid&"&lang=zh_CN","")
			set java_obj=java_eval("(" &xml_text& ")")
			Session("openid")=openid
			Session("subscribe")=java_obj.subscribe
			if err.number then'{"errcode":40001,"errmsg":"invalid credential"}
				'获取失败，将重新尝试
				'Set fs = CreateObject("Scripting.FileSystemObject")
				'Set f = fs.OpenTextFile(server.MapPath("err.txt"), 8, True)
				'f.WriteLine now
				'f.WriteLine openid
				'f.WriteLine xml_text
				'f.close
				'============================
				xml_text=post("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="&appId&"&secret="&appSecret,"")
				set java_obj=java_eval("(" &xml_text& ")")
				access_token=java_obj.access_token
				xml_text=post("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token="&access_token&"&type=jsapi","")
				set java_obj=java_eval("(" &xml_text& ")")
				jsapi_ticket=java_obj.ticket
				conn.execute("update weixin set access_token='"&access_token&"',jsapi_ticket='"&jsapi_ticket&"',access_time='"&now&"'")
				xml_text=post("https://api.weixin.qq.com/cgi-bin/user/info?access_token="&access_token&"&openid="&openid&"&lang=zh_CN","")
				set java_obj=java_eval("(" &xml_text& ")")
				Session("subscribe")=java_obj.subscribe
			end if
			Session("headimgurl")="img/head.png"
			Session("nickname")="未关注"
			Session("weixin")=1
			Session("appid")=appId
			'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8136fbf8148b70c0&redirect_uri=http://www.mopiv.com/&response_type=code&scope=snsapi_base&state=STATE&connect_redirect=1#wechat_redirect
			if java_obj.subscribe then
				Session("headimgurl")=left(java_obj.headimgurl,len(java_obj.headimgurl)-1)&"96"
				Session("nickname")=java_obj.nickname
			end if
		end if
	end if
	'==========================================================================
	'openid=request("openid")
	'if openid<>"" then Session("openid")=openid else openid=Session("openid")
	'==========================================================================设置分享连接
	strSQL = "select top 1 * from customer where c_no='" & userID & "'"
	set oRs=conn.Execute(strSQL)
	if oRs.eof then 
		Session.Abandon
		gotourl "login.asp",1 
	end if
	'set oRs=conn.Execute("select count(*)  from orderVIEW where (o_state=0) and (c_no='" & userID & "')")
	'v1=oRs(0)
	'set oRs=conn.Execute("select count(*)  from orderVIEW where (o_state=1) and (c_no='" & userID & "')")
	'v2=oRs(0)
	'set oRs=conn.Execute("select count(*)  from orderVIEW where (o_state=2) and (c_no='" & userID & "')")
	'v3=oRs(0)
	
	'set oRs=conn.Execute("select count(*)  from orderVIEW where (o_state=0) and (c_no_p='" & userID & "')")
	'v4=oRs(0)
	'set oRs=conn.Execute("select count(*)  from orderVIEW where (o_state=1) and (c_no_p='" & userID & "')")
	'v5=oRs(0)
	'set oRs=conn.Execute("select count(*)  from orderVIEW where (o_state=2) and (c_no_p='" & userID & "')")
	'v6=oRs(0)
	'set oRs=conn.Execute("select c_nowpoint  from customer where (c_no='" & userID & "')")
	'v7=oRs(0)
	set oRs=conn.Execute("SELECT Sum(p_price) AS sumprice, Count(o_no) AS total FROM orderVIEW where (o_date=date())and(c_no_p='" & userID & "')")
	d1=val(oRs("sumprice")&"")
	d2=val(oRs("total")&"")
	set oRs=conn.Execute("SELECT Sum(p_price) AS sumprice, Count(o_no) AS total FROM orderVIEW where (o_date>=#"&year(date)&"-"&Month(date)&"-01#)and(c_no_p='" & userID & "')")
	m1=val(oRs("sumprice")&"")
	m2=val(oRs("total")&"")
	set oRs=conn.Execute("SELECT Sum(p_price) AS sumprice, Count(o_no) AS total FROM orderVIEW where (c_no_p='" & userID & "')")
	a1=val(oRs("sumprice")&"")
	a2=val(oRs("total")&"")
	function isWeixin()
		isWeixin=instr(1,Request.ServerVariables("HTTP_USER_AGENT"),"MicroMessenger",1)
		isWeixin=0
	end function
%>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title>订货管理系统-首页</title>
<link rel="stylesheet" href="../inc/jquery.bxslider.css">
<link rel="stylesheet" href="../inc/css.css">
<link rel="stylesheet" href="../inc/pz/pz-mobile.css">
<script src="../inc/jquery-1.9.0.min.js"></script>
<script src="../inc/jquery.bxslider.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){$('.bxslider').bxSlider({captions:true, speed:300, pause:5000, mode:'horizontal', auto:true });})
</script>
<style>
body{background:#fff}
p{margin:0px;}
.panel_ul{margin:5px;list-style:none; padding:0}
.show_li{padding:0;width:50%; float:left;-webkit-box-shadow: 0px 1px 2px rgba(0,0,0,0.2);box-shadow: 0px 1px 2px rgba(0,0,0,0.2);}
.show_li img{width:100%;}
.show_li div{padding:5px;height:65px;background:#fff;}
.show_li .show_name{ font-size:13px;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;display:block;}
.show_li b{font-size:15px;color:#FF0000;padding-right:5px}
.show_li del{font-size:12px;color:#666;}
.show_li .point{font-size:12px;color:green;display:block;}
.show_li a{display:block; background:#fff}
.show_bottom{width:100%;}
.show_bottom img{max-width:100%}
.navt{list-style-type:none;text-align:center; margin:0; padding:0;}
.navt li{width:32.6%;float:left; border-right:1px solid #ccc;cursor:pointer;}
.navt img{display:inline; width:40px; height:40px}
.navt p{font-size:12px; margin:5px; color:#666}
.pzpanel{background:#eedddd;padding:10px; margin:10px;border: 0px solid #fff;position:relative;}
.panel{ position:relative;width:50%; vertical-align:text-top; padding:15px 0 0 15px; background:#e8e8e8; float:left; height:95px; border:5px #fff solid; box-sizing: border-box;}
.panel div{position:absolute;left:70px; top:15px}
.tab{height:50px; width:50px; margin-right:5px; display:inline-block;background:url(../img/icon-c.png) no-repeat;background-size:620%;}
</style>
</head>
<body>
	<ul class="top-tool">
		<li class="title">首页</li>
		<li class="back"></li><li class="home"><a style="float:right;margin-right:5px;" href="cart.asp"></a><span style="float:right;margin:20px 0px;font-size:14px">购物车</span></li>
	</ul>
	<div style="height:50px"></div>
	
	<div class="pzpanel" style="background:#ffeaea;">
		<div class="pz-panel" style="background:#ff9999;height:60px;width:60px; line-height:60px; padding:0;font-size:18px; text-align:center; color:#fff">
		今天</span>
		</div>
		<div align="right" style="position:absolute;font-size:24px; right:10px;color:#ff9999;top:15px"><%=FormatCurrency(d1,2,true)%></div>
		<div align="right" style="position:absolute;font-size:18px; right:10px;color:#aa9999;top:40px"><%=d2%> 笔</div>
	</div>
	<div class="pzpanel" style="background:#eaffea;">
		<div class="pz-panel" style="background:#99cb99;height:60px;width:60px; line-height:60px; padding:0;font-size:18px; text-align:center; color:#fff">
		本月</span>
		</div>
		<div align="right" style="position:absolute;font-size:24px; right:10px;color:#99bb99;top:15px"><%=FormatCurrency(m1,2,true)%></div>
		<div align="right" style="position:absolute;font-size:18px; right:10px;color:#99aa99;top:40px"><%=m2%> 笔</div>
	</div>
	<div class="pzpanel" style="background:#eaeaff;">
		<div class="pz-panel" style="background:#55aadd;height:60px;width:60px; line-height:60px; padding:0;font-size:18px; text-align:center; color:#fff">
		总计</span>
		</div>
		<div align="right" style="position:absolute;font-size:24px; right:10px;color:#4499bb;top:15px"><%=FormatCurrency(a1,2,true)%></div>
		<div align="right" style="position:absolute;font-size:18px; right:10px;color:#4499aa;top:40px"><%=a2%> 笔</div>
	</div>
	<!--
	<div style="padding:0px;position:relative;background:#fff; border-bottom:#ddd 1px solid">
		<div style="font-size:14px;border-bottom:#ddd 1px solid;padding:10px">我的订单</div>
		<ul class="navt">
			<li onClick="location.href='order_list.asp'">
				<p style="font-size:16px">待审核</p><p><span style="font-size:18px; color:#009900"><%=v1%></span></p>
			</li>
			<li onClick="location.href='order_list.asp'">
				<p style="font-size:16px">待发货</p><p><span style="font-size:18px; color:#009900"><%=v2%></span></p>
			</li>
			<li style="border-right:none" onClick="order_list.asp'">
				<p style="font-size:16px">待收货</p><p><span style="font-size:18px; color:#009900"><%=v3%></span></p>
			</li>
		</ul>
		<div style="clear:left"></div>
	</div>
	
	<div style="padding:0px;position:relative;background:#fff; border-bottom:#ddd 1px solid">
		<div style="font-size:14px; border-bottom:#ddd 1px solid;padding:10px">代理订单</div>
		<ul class="navt">
			<li onClick="location.href='order_list.asp'">
				<p style="font-size:16px">待审核</p><p><span style="font-size:18px; color:#009900"><%=v4%></span></p>
			</li>
			<li onClick="location.href='order_list.asp'">
				<p style="font-size:16px">待发货</p><p><span style="font-size:18px; color:#009900"><%=v5%></span></p>
			</li>
			<li style="border-right:none" onClick="order_list.asp'">
				<p style="font-size:16px">待收货</p><p><span style="font-size:18px; color:#009900"><%=v6%></span></p>
			</li>
		</ul>
		<div style="clear:left"></div>
	</div>
	-->
	<div style="padding:5px">
	<div class="panel" onClick="window.location='financial_report.asp'"><span class="tab" style="background-position:-96px -555px"></span><div><span style="font-size:24px; display:block">财务</span><small>月帐务报表</small></div></div>
	<div class="panel" onClick="window.location='money_report.asp'"><span class="tab" style="background-position:-245px -607px"></span><div><span style="font-size:24px; display:block">回款</span><small>月回款金额报表</small></div></div>
	<div class="panel" onClick="window.location='sell_report.asp'"><span class="tab" style="background-position:-145px -607px"></span><div><span style="font-size:24px; display:block">销售</span><small>月帐户金额报表</small></div></div>
	<div class="panel" onClick="window.location='stock_report.asp'"><span class="tab" style="background-position:-96px -607px"></span><div><span style="font-size:24px; display:block">库存</span><small>商品库存报表</small></div></div>
	</div>
<!--#include file="bottom.asp"-->
</body></html>